package com.platform;

import java.net.InetAddress;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;

import com.platform.ext.swagger.EnableSwagger2Doc;

//启动项目，禁止系统自动装配数据源
@SpringBootApplication(exclude = {
		DataSourceAutoConfiguration.class,
		MongoAutoConfiguration.class,
		MongoDataAutoConfiguration.class
})
@ImportResource(locations= {"classpath:spring-other.xml"})
@ComponentScan(basePackages ={"com.platform.**"})
@ServletComponentScan
@EnableSwagger2Doc
@EnableAsync
public class PlatformSingleApplication{ 

	private static final Logger log = LoggerFactory.getLogger(PlatformSingleApplication.class);
	
	public static void main(String[] args) throws Exception{
		ConfigurableApplicationContext app = SpringApplication.run(PlatformSingleApplication.class, args);
		Environment env = app.getEnvironment();
        log.info("\n----------------------------------------------------------\n\t" +
                        "应用 '{}' 运行成功! \n\t" +
                        "地址:{}:{}/{}\n\t"+
                        "配置环境:{}\n"+
                "----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"),
                env.getProperty("server.servlet.context-path"),
        		env.getActiveProfiles()
        );

	}
}
